﻿<sap:ActivityDesigner x:Class="Vision.Core.ActivityComponents.Xml.XmlOpenDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities"
    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
    Collapsible="True"
    ExpandState="True"
    Icon="{DynamicResource DesignerIcon}">
    <sap:ActivityDesigner.Resources>
        <DrawingBrush x:Key="DesignerIcon" Stretch="Uniform">
            <DrawingBrush.Drawing>
                <DrawingGroup>
                    <DrawingGroup.Children>
                        <GeometryDrawing Geometry="F1 M 150.666,61.6685L 150.666,126.334L 84.9994,126.334L 84.9998,39.3341L 125.995,39.3333C 131.775,43.2222 137.554,47.1112 141.666,50.8337C 145.778,54.5562 148.222,58.1124 150.666,61.6685 Z ">
                            <GeometryDrawing.Pen>
                                <Pen LineJoin="Round" Brush="#FF41588D"/>
                            </GeometryDrawing.Pen>
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="-0.527907,0.681985" EndPoint="1.30457,0.681985">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FF7D9DE5" Offset="0"/>
                                        <GradientStop Color="#FFCEDDFF" Offset="1"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                        <GeometryDrawing Geometry="F1 M 87.9998,94.6671L 147.667,94.6668L 147.667,123.333L 87.9998,123.334L 87.9998,94.6671 Z ">
                            <GeometryDrawing.Pen>
                                <Pen LineJoin="Round" Brush="#FF41588D"/>
                            </GeometryDrawing.Pen>
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="-0.46135,0.49999" EndPoint="1.05912,0.49999">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FF295078" Offset="0"/>
                                        <GradientStop Color="#FF456E97" Offset="0.278662"/>
                                        <GradientStop Color="#FF628CB6" Offset="0.525862"/>
                                        <GradientStop Color="#FF295078" Offset="1"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                        <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 91.2,119.333L 97.6958,109.779L 91.5125,100.133L 94.625,100.133L 99.3,107.425L 104.262,100.133L 106.779,100.133L 100.521,109.333L 106.933,119.333L 103.821,119.333L 98.9167,111.688L 93.7167,119.333L 91.2,119.333 Z "/>
                        <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 110.267,119.333L 110.267,100.133L 114.192,100.133L 119.2,115.067L 124.571,100.133L 127.867,100.133L 127.867,119.333L 125.467,119.333L 125.467,103.867L 120.358,118.071L 117.433,118.071L 112.667,103.867L 112.667,119.333L 110.267,119.333 Z "/>
                        <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 133.2,119.333L 133.2,100.133L 135.867,100.133L 135.867,117.467L 144.4,117.467L 144.4,119.333L 133.2,119.333 Z "/>
                        <GeometryDrawing Geometry="F1 M 150.667,61.6666C 147.667,60.8888 144.667,60.111 140.889,60.0555C 137.111,59.9999 132.556,60.6666 128,61.3333C 128.667,57.8889 129.333,54.4444 129,50.7778C 128.667,47.1111 127.333,43.2222 126,39.3333">
                            <GeometryDrawing.Pen>
                                <Pen LineJoin="Round" Brush="#FF41588D"/>
                            </GeometryDrawing.Pen>
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="1.38867,-0.155539" EndPoint="4.30589,-0.155539">
                                    <LinearGradientBrush.RelativeTransform>
                                        <TransformGroup>
                                            <SkewTransform CenterX="1.38867" CenterY="-0.155539" AngleX="-3.28044" AngleY="0"/>
                                            <RotateTransform CenterX="1.38867" CenterY="-0.155539" Angle="133.36"/>
                                        </TransformGroup>
                                    </LinearGradientBrush.RelativeTransform>
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FF93C3F3" Offset="0"/>
                                        <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                    </DrawingGroup.Children>
                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>

        <sapc:ArgumentToExpressionConverter x:Uid="sadv:ArgumentToExpressionConverter_1" x:Key="argumentToExpressionConverter" />

        <DataTemplate x:Key="ExpandedActivityDesignerTemplate">
            <StackPanel>
                <!-- Inputs Header -->
                <TextBlock Text="Input(s):" FontWeight="Bold" Foreground="Navy" Margin="0,0,0,3" />

                <Grid Margin="0,5,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <!-- ModelItem.FileData -->
                    <TextBlock Grid.Row="1" Grid.Column="0" Text="File data:" VerticalAlignment="Top" />
                    <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1" x:Name="fileDataBox"
                                MaxLines="1" Margin="7,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                Expression="{Binding Path=ModelItem.FileData, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=In}"
                                ExpressionType="{Binding Path=ModelItem.FileData.ArgumentType}"
                                OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}" />
                </Grid>

                <!-- Outputs Header -->
                <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="Outputs(s):" FontWeight="Bold" Foreground="Navy" Margin="0,5,0,3" />

                <Grid Margin="0,5,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <!-- ModelItem.XmlDocument -->
                    <TextBlock Grid.Row="1" Grid.Column="0" Text="Output data:" VerticalAlignment="Top" />
                    <sapv:ExpressionTextBox Grid.Row="1" Grid.Column="1" x:Name="xmlDocumentBox"
                                MaxLines="1" Margin="7,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                Expression="{Binding Path=ModelItem.XmlDocument, Mode=TwoWay, Converter={StaticResource argumentToExpressionConverter}, ConverterParameter=Out}"
                                ExpressionType="{Binding Path=ModelItem.XmlDocument.ArgumentType}"
                                OwnerActivity="{Binding Path=ModelItem, Mode=OneWay}"
                                UseLocationExpression="True" />
                </Grid>

                <Border BorderThickness="0,0,0,3" Margin="0,5">
                    <Border.BorderBrush>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="DarkGray" Offset="0" />
                            <GradientStop Color="White" Offset="1" />
                        </LinearGradientBrush>
                    </Border.BorderBrush>
                </Border>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" x:Uid="TextBlock_5" Text="Argument:" VerticalAlignment="Top" Foreground="Gray" />
                    <TextBox Grid.Row="0" Grid.Column="1" x:Uid="TextBox_1" Text="{Binding Path=ModelItem.Body.Argument.Name, Mode=TwoWay}" Margin="7,0,0,0" Foreground="Gray" />
                </Grid>
                <!-- Body -->
                <sap:WorkflowItemPresenter x:Uid="sad:WorkflowItemPresenter_1" AutomationProperties.AutomationId="Activity" IsDefaultContainer="True" HintText="Drop activity here" Item="{Binding Path=ModelItem.Body.Handler, Mode=TwoWay}" AllowedItemType="{x:Type sa:Activity}" MinWidth="100" MinHeight="100" Margin="0,7,0,0"/>

            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="CollapsedActivityDesignerTemplate">
            <Label Padding="0,0,0,0" FontStyle="Italic" Foreground="{x:Static SystemColors.GrayTextBrush}" HorizontalAlignment="Center" VerticalAlignment="Center">Double-click to view</Label>
        </DataTemplate>
        <Style x:Uid="Style_1" x:Key="DesignerStyle" TargetType="{x:Type ContentPresenter}">
            <Setter x:Uid="Setter_1" Property="ContentTemplate" Value="{DynamicResource ExpandedActivityDesignerTemplate}" />
            <Style.Triggers>
                <DataTrigger x:Uid="DataTrigger_1" Binding="{Binding Path=ShowExpanded}" Value="false">
                    <Setter x:Uid="Setter_2" Property="ContentTemplate" Value="{DynamicResource CollapsedActivityDesignerTemplate}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </sap:ActivityDesigner.Resources>
    
    <ContentPresenter x:Uid="ContentPresenter_1" Style="{DynamicResource DesignerStyle}" Content="{Binding}" />
</sap:ActivityDesigner>
